package cuentas;

public class Resumen implements Runnable{
	
	
	Thread thr;
	Ventana v;
	IThreadOperaciones itr;
	
	
public Resumen(Ventana v, IThreadOperaciones itr){
	
	thr=new Thread(this, "Resumen");
	thr.start();
	v.lbl1.setText("Fin thread Resumen.");
	
}

public void run(){
	
	while (thr == Thread.currentThread()){	
	for(int i=0; i<v.listModel1.getSize();i++){
		
		CuentaCorriente cc=(CuentaCorriente) v.listModel1.elementAt(i);
		
		if((cc.tipo==1)|(cc.tipo==3)){
			cc.monto=cc.montofinal+cc.monto;
			cc.monto=cc.montofinal;
			v.listModel3.addElement(cc);
		
			try {
				thr.sleep((long) (Math.random()*itr.ESPERA_MAXIMA));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
		
		else{
			cc.monto=cc.montofinal-cc.monto;
			cc.monto=cc.montofinal;
			v.listModel2.addElement(cc);
		
			try {
				thr.sleep((long) (Math.random()*itr.ESPERA_MAXIMA));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
		
	}
	}
}
	

}
